package com.cb.kfc.dao;

import com.cb.kfc.domain.Product;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface IProductDao {

    //查询所有会员的种类信息
    @Select("select * from product")
    public List<Product> findAll() throws Exception;

    @Insert("insert into product(productNum,productName,productPrice,productDesc) values(#{productNum},#{productName},#{productPrice},#{productDesc})")
    void save(Product product);

    //删除单个，或者批量删除
    @Delete("<script>delete from product where id in <foreach collection='array' item='id' open='(' separator=',' close=')'>#{id}</foreach> </script>")
    Integer delete(String[] ids);

    //查找单个会员类别
    @Select("select * from product where id = #{id}")
    Product findOne(String id);

    //更新一个会员类别 productNum,productName,productPrice,productDesc
    @Update("update product set  productNum=#{productNum},productName=#{productName},productPrice=#{productPrice} ,productDesc=#{productDesc} where id =#{id} ")
    int update(Product product);


}
